package org.one.afternoon.quartz;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.Date;

@PersistJobDataAfterExecution //持久化
@DisallowConcurrentExecution //禁止并发任务
public class QuartzJob extends QuartzJobBean {
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        try {
            Thread.sleep(2000);
            System.out.println(context.getScheduler().getSchedulerInstanceId());

            System.out.println("taskName:"+context.getJobDetail().getKey().getName());

            System.out.println("time:"+new Date());


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
